home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / comm / mail / ftpget10.lha / FTPGet.thor < prev   
Text File  |  1995-08-31  |  5KB  |  168 lines

  1. /*
  2. ** $VER: FTPGet.thor 1.0 (29.5.95)
  3. **
  4. ** by Eirik Nicolai Synnes
  5. **
  6. ** This script will let you select AmiNet files for ftp'ing either from a
  7. ** AmiNet RECENT listing produced by SortMail or from Thor's filebase. If
  8. ** the filebase window is open, the files selected there will be used.
  9. ** Otherwise FTPGet.thor will open a listview containing the RECENT listing.
  10. **
  11. ** FTPGet.thor is to be used together with FTPGet.daftp. The latter will
  12. ** read the list created by FTPGet.thor and get the files from the AmiNet
  13. ** site. Note that you will have to connect to the site yourself, but
  14. ** FTPGet.daftp will CD to the correct directory and start the downloading.
  15. **
  16. ** FTPGet.daftp has been tested with DaFTP 0.1130 and found to work
  17. ** satisfactory. FTPGet.thor needs Thor 2.0 or higher to work.
  18. **
  19. ** Before using these scripts, edit the listfile and getreadme variables
  20. ** below. FTPGet.daftp also contains two variables that must be edited
  21. ** before use.
  22. ** 
  23. */
  24.  
  25. /* Edit these variables: */
  26.  
  27. listfile = 'Thor:GetFiles.txt'  /* This must be the same in FTPGet.thor and FTPGet.daftp */
  28. getreadme = 1                   /* 0 if you don't want readme's, 1 if you do */
  29.  
  30. /* End */
  31.  
  32. options results
  33.  
  34. FDF_DELETED = '00000001'x
  35. path = ''
  36.  
  37. /* Open Thor and BBSREAD ARexx ports' */
  38. p=address()||' '||show('P',,);if pos('THOR.',p)>0 then thorport=word(substr(p,pos('THOR.',p)),1);else do;say 'No THOR port found!';exit(0);end
  39. if ~show('p', 'BBSREAD') then do; address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"; "WaitForPort BBSREAD"; end
  40.  
  41. address(thorport)
  42. GETFILELIST OUTSTEM files
  43. select
  44.     when rc = 0 then do
  45.         CURRENTBBS STEM bbs
  46.         if rc > 1 then do
  47.             REQUESTNOTIFY '"'THOR.LASTERROR'"' '"Ok"'
  48.             exit(0)
  49.             end
  50.  
  51.         if exists(listfile) then call open(df, listfile, 'A')
  52.         else call open(df, listfile, 'W')
  53.  
  54.         do i=1 to files.COUNT
  55.             drop FILE. /* Important */
  56.  
  57.             address (bbsread)
  58.             SEARCHBRFILE '"'bbs.BBSNAME'"' FILE SEARCH '"'files.FILENAME.i'"' NAME
  59.             if rc ~= 0 then do
  60.                 address(thorport)
  61.                 REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
  62.                 exit(0)
  63.                 end
  64.  
  65.             if FILE.FILEAREA.COUNT ~= 0 then do
  66.                 drop FTAGS.; drop FDATA.
  67.                 READBRFILE '"'bbs.BBSNAME'"' '"'FILE.FILEAREA.1'"' FILENR files.FILENR.i tagsstem FTAGS datastem FDATA
  68.                 if(rc ~= 0) then do
  69.                     address(thorport)
  70.                     REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
  71.                     call close(df)
  72.                     exit(0)
  73.                     end
  74.  
  75.                 if bitand(DATA.FLAGS,FDF_DELETED) ~= FDF_DELETED then path = do
  76.                     path = FILE.FILEAREA.1'/'FTAGS.NAME
  77.                     if getreadme = 1 then do
  78.                         path = path' 'substr(path, 1, lastpos('.', subword(path, 1, 1)))'readme'
  79.                         end
  80.                     call writeln(df, path)
  81.                 end
  82.             end
  83.         call close(df)
  84.         end
  85.     when rc = 6 then do
  86.         REQUESTNOTIFY '"Please select some files."' '"Ok"'
  87.         end
  88.     when rc = 5 then do
  89.         /* Filebase not open, get Newfiles.txt if available */
  90.         CURRENTBBS STEM bbs
  91.         if rc > 1 then do
  92.             REQUESTNOTIFY '"'THOR.LASTERROR'"' '"Ok"'
  93.             exit(0)
  94.             end
  95.  
  96.         address(bbsread)
  97.         GETBBSDATA BBSNAME '"'bbs.BBSNAME'"' STEM bbsdata
  98.         if rc ~= 0 then do
  99.             address(thorport)
  100.             REQUESTNOTIFY '"'BBSREAD.LASTERROR'"' '"Ok"'
  101.             exit(0)
  102.             end
  103.  
  104.         if exists(bbsdata.BBSPATH'Newfiles.txt') then do
  105.             /* Open and read Newfiles.txt, skipping irrelevant lines */
  106.             call open(nf, bbsdata.BBSPATH'Newfiles.txt', 'R')
  107.             counter = 0
  108.             do until eof(nf)
  109.                 line = readln(nf)
  110.                 if left(line, 1) ~= '|' & line ~= '' then do
  111.                     counter = counter + 1
  112.                     entry.counter = line
  113.                     end
  114.                 end
  115.             call close(nf)
  116.             entry.count = counter
  117.  
  118.             if entry.count > 0 then do
  119.                 /* Put up a listview with the files */
  120.                 address(thorport)
  121.                 REQUESTLIST INSTEM entry OUTSTEM select TITLE '"Select files"' DRAGSELECT SIZEGADGET
  122.                 if rc ~= 0 then do
  123.                     if rc > 5 then do
  124.                         REQUESTNOTIFY '"'rc'\n'THOR.LASTERROR'"' '"Ok"'
  125.                         end
  126.                     exit(0)
  127.                     end
  128.  
  129.                 if select.COUNT = 0 then do
  130.                     /* One file was selected */
  131.                     path = subword(result, 2, 1)'/'subword(result, 1, 1)
  132.                     if substr(result, 35, 1) = '+' & getreadme = 1 then do
  133.                         path = path' 'substr(path, 1, lastpos('.', subword(path, 1, 1)))'readme'
  134.                         end
  135.                     if exists(listfile) then call open(df, listfile, 'A')
  136.                     else call open(df, listfile, 'W')
  137.                     call open(df, listfile, 'A')
  138.                     call writeln(df, path)
  139.                     call close(df)
  140.                     end
  141.  
  142.                 else do
  143.                     if exists(listfile) then call open(df, listfile, 'A')
  144.                     else call open(df, listfile, 'W')
  145.                     do i = 1 to select.COUNT
  146.                         /* Multiple files were selected */
  147.                         path = subword(select.i, 2, 1)'/'subword(select.i, 1, 1)
  148.                         if substr(select.i, 35, 1) = '+' & getreadme = 1 then do
  149.                             path = path' 'substr(path, 1, lastpos('.', subword(path, 1, 1)))'readme'
  150.                             end
  151.                         call writeln(df, path)
  152.                     end
  153.                     call close(df)
  154.                     end
  155.                 end
  156.             end
  157.         else do
  158.             /* No Newfiles.txt found */
  159.             REQUESTNOTIFY '"No new files on system."' '"Ok"'
  160.             end
  161.         end
  162.     otherwise do
  163.         REQUESTNOTIFY '"'THOR.LASTERROR'"' '"Ok"'
  164.         end
  165.     end
  166.  
  167. exit(0)
  168.